import {createApp} from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import { usePermissStore } from './store/permiss'
import 'element-plus/dist/index.css'
import './assets/css/icon.css'
import {AxiosInstance } from "axios";
// import 'lib-flexible/flexible.js'
// import "./normalize.css";
import Axios from "axios";
import 'jquery'

// 引入echarts
//import echarts from './echarts.js' //按需引入
// echarts-4.0

// 引入echarts-5.0
import * as echarts from 'echarts'

// 挂载到vue实例中
// Vue.prototype.$echarts = echarts;//vue2的挂载方式

const app = createApp(App)

app.config.globalProperties.$echarts = echarts;//vue3的挂载方式

declare module '@vue/runtime-core' {
    interface ComponentCustomProperties {
        $axios: AxiosInstance;
    }
}
app.config.globalProperties.$axios=Axios;  //this.Axios

app.use(createPinia())
app.use(router)
// app.use(tencentcloud)
app.use(ElementPlus)

// 注册elementplus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// 自定义权限指令
const permiss = usePermissStore()
app.directive('permiss', {
    mounted(el, binding) {
        if(!permiss.key.includes(String(binding.value))){
            el['hidden'] = true;
        }
    }
})
app.provide('$echarts', echarts);
app.mount('#app')
